//
//  JXLSearchView.swift
//  MicroBlog
//
//  Created by 贾晓磊 on 16/9/20.
//  Copyright © 2016年 贾晓磊. All rights reserved.
//

import UIKit

class JXLSearchView: UIView {

   //搜索按钮
    @IBOutlet weak var searchButton: UIButton!
    //搜索文本框
    @IBOutlet weak var searchTextField: UITextField!
    //搜索框的右边界
    @IBOutlet weak var searchTextFieldRightConstraint: NSLayoutConstraint!
    // MARK: 方法＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝
    
   //点击button
    @IBAction func searchButtonAction(_ sender: AnyObject) {
        searchTextField.resignFirstResponder()
        searchTextFieldRightConstraint.constant = 0
        
        UIView.animate(withDuration: 0.5) {
            self.layoutIfNeeded()
        }

    }
    //点击textField
    @IBAction func searchTextFieldAction(_ sender: AnyObject) {
        searchTextFieldRightConstraint.constant = searchButton.width
        
        UIView.animate(withDuration: 0.5) {
            self.layoutIfNeeded()
        }
    }
    
    //快速创建的类方法
    class func searchView() -> JXLSearchView {
        return UINib(nibName: "JXLSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! JXLSearchView
    }
    
    //在awakeFromNib方法中设置searchTextField
//    override func awakeFromNib() {
//        searchTextField.layer.borderColor = UIColor.orange.cgColor
//        searchTextField.layer.borderWidth = 2
//        searchTextField.layer.cornerRadius = 5
//        searchTextField.layer.masksToBounds = true
//    }
    
    
    
    
}
